<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <span >小米笔记本电脑</span><button onclick="edit(this)">编辑</button>

</div>



<script>



    /*点击编辑即可要修改的内容*/

    function edit(element) {

        element.innerHTML="保存";

        var prev=element.previousSibling;

        var oldhtml=prev.innerHTML;

        prev.innerHTML="";

        var newObj=document.createElement("textarea");

        newObj.className="textArea";

        newObj.innerHTML=oldhtml;

        prev.appendChild(newObj);

        newObj.focus();

        newObj.onblur=function(){

            alert(prev.id);

            element.innerHTML="编辑";

            prev.innerHTML=this.value?this.value:oldhtml;

        }

    }





</script>


</body>
</html>